﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TestXNA3.Render;
using TestXNA3.Resources;
using TestXNA3.Actors;
using System.Runtime.Serialization;
using Microsoft.Xna.Framework;

namespace TestXNA3.Components
{
    [Serializable]
    class DirectionalLightComponent : Component
    {
        public override void AddToRenderQueue(SceneRenderer sceneRenderer, ref List<MeshResource> meshes)
        {
            SceneRenderer.LightDesc lightDesc = new SceneRenderer.LightDesc();

            lightDesc.Type = SceneRenderer.ELightType.Directional;
            lightDesc.Location = Parent.Location;
            lightDesc.Diffuse = ((DirectionalLight)Parent).Diffuse;
            lightDesc.Specular = ((DirectionalLight)Parent).Specular;
            lightDesc.Intensity = ((DirectionalLight)Parent).Intensity;
            lightDesc.Direction = Vector3.Normalize(Parent.Forward);
            lightDesc.Up = Vector3.Normalize(Parent.Up);
            lightDesc.Fov = 60.0f;
            lightDesc.Far = 12000f;
            lightDesc.Near = 20f;
            lightDesc.CastShadows = ((DirectionalLight)Parent).CastShadows;

            sceneRenderer.PushLight(ref lightDesc);
        }

        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);
        }
    }
}
